<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <ul id="ul"></ul>
</body>
<script>
    // 这是什么什么
    var a = [2, 3, 4, 5, 6];

    // forEach

    a.forEach(function (val, index, arr) {
        console.log(val, index, arr);
        var li = document.createElement("li"); //创建li
        li.innerHTML = arr; //给li添加innerHtml
        document.getElementById("ul").appendChild(li); //把li添加到ul中
    });

    // map
    var b = a.map(function (val, index, arr) {
        return arr;
    });

    console.log(b)

    //filter
    var c = a.filter(function (val, index, arr) {
        return val % 2 == 0;
    })

    console.log(c);


    function Animal(name,age) {
        this.name = name;
        this.age = age;
        this.a = age>=3?"老了":"年轻";
    }

    var cat = new Animal("小猫","2");
    var dog = new Animal("小狗","4");
    

    console.log(cat,dog);

    function fun1(name){
        return {
            "nameqq":name
        }
    }

    function fun2(func,arg) {
        return func(arg);
    }

    console.log(fun2(fun1,"臭笨"))

</script>

</html>